#!/bin/sh 
#/usr/local/nginx/sbin/nginx 
#echo ">>>>>>>>>>install dos2unix<<<<<<<<<"
#if [[ -n $(yum list installed |grep dos2unix) ]]; then
#    echo "已安装dos2unix" 
#else
#    yum -y install dos2unix
#    echo "安装dos2unix完毕" 
#fi
echo ">>>>>>>>>>yum install gcc-c++<<<<<<<<<"
if [[ -n $(yum list installed |grep gcc-c++) ]]; then
    echo "已安装gcc-c++"
else
    yum -y install gcc-c++
    echo "安装gcc-c++完毕"
fi
if [[ -n $(yum list installed |grep pcre) ]]; then
    echo "已安装pcre"
else
    yum -y install pcre
    echo "安装pcre完毕"
fi
if [[ -n $(yum list installed |grep pcre-devel) ]]; then
    echo "已安装pcre-devel"
else
    yum -y install pcre-devel
    echo "安装pcre-devel完毕"
fi

if [[ -n $(yum list installed |grep zlib) ]]; then
    echo "已安装zlib"
else
    yum -y install zlib
    echo "安装zlib完毕"
fi
if [[ -n $(yum list installed |grep zlib-devel) ]]; then
    echo "已安装zlib-devel"
else
    yum -y install zlib-devel
    echo "安装zlib-devel完毕"
fi
if [[ -n $(yum list installed |grep libxml2) ]]; then
    echo "已安装libxml2"
else
    yum -y install libxml2
    echo "安装libxml2完毕"
fi
if [[ -n $(yum list installed |grep libxml2-devel) ]]; then
    echo "已安装libxml2-devel"
else
    yum -y install libxml2-devel
    echo "安装libxml2-devel完毕"
fi
if [[ -n $(yum list installed |grep libxslt-devel) ]]; then
    echo "已安装libxslt-devel"
else
    yum -y install libxslt-devel
    echo "安装libxslt-devel完毕"
fi
if [[ -n $(yum list installed |grep openssl-devel) ]]; then
    echo "已安装openssl-devel"
else
    yum -y install openssl-devel
    echo "安装openssl-devel完毕"
fi
if [[ -n $(yum list installed |grep gd-devel) ]]; then
    echo "已安装gd-devel"
else
    yum -y install gd-devel
    echo "安装gd-devel完毕"
fi
if [[ -n $(yum list installed |grep GeoIP) ]]; then
    echo "已安装GeoIP"
else
    yum -y install GeoIP
    echo "安装GeoIP完毕"
fi
if [[ -n $(yum list installed |grep GeoIP-devel) ]]; then
    echo "已安装GeoIP-devel"
else
    yum -y install GeoIP-devel
    echo "安装GeoIP-devel完毕"
fi
if [[ -n $(yum list installed |grep GeoIP-data) ]]; then
    echo "已安装GeoIP-data"
else
    yum -y install GeoIP-data
    echo "安装GeoIP-data完毕"
fi
if [[ -n $(yum list installed |grep perl) ]]; then
    echo "已安装perl"
else
    yum -y install perl
    echo "安装perl完毕"
fi
if [[ -n $(yum list installed |grep perl-devel) ]]; then
    echo "已安装perl-devel"
else
    yum -y install perl-devel
    echo "安装perl-devel完毕"
fi
if [[ -n $(yum list installed |grep perl-ExtUtils-Embed) ]]; then
    echo "已安装perl-ExtUtils-Embed"
else
    yum -y install perl-ExtUtils-Embed
    echo "安装perl-ExtUtils-Embed完毕"
fi
if [[ -n $(yum list installed |grep libatomic_ops-devel) ]]; then
    echo "已安装libatomic_ops-devel"
else
    yum -y install libatomic_ops-devel
    echo "安装libatomic_ops-devel完毕"
fi


echo ">>>>>>>>>>download nginx1.14<<<<<<<<<"
mkdir -p /home/install
cd /home/install
wget -O nginx-1.14.0.tar.gz https://cd-1251357415.cos.ap-chengdu.myqcloud.com/nginx/nginx-1.14.0.tar.gz
echo ">>>>>>>>>>build nginx1.14<<<<<<<<<"
ls -l nginx-1.14.0.tar.gz
useradd -M -s /sbin/nologin nginx
tar zxf nginx-1.14.0.tar.gz
mkdir -p /usr/local/nginx
cd /home/install/nginx-1.14.0
yum -y update openssl
./configure --prefix=/usr/local/nginx --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --http-fastcgi-temp-path=/var/lib/nginx/fastcgi  --http-proxy-temp-path=/var/lib/nginx/proxy --http-client-body-temp-path=/var/lib/nginx/body --with-debug --with-select_module --with-http_flv_module --with-http_mp4_module --with-poll_module --with-file-aio --with-pcre --with-pcre-jit  --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads
#nginx path prefix: "/usr/local/nginx"
#nginx binary file: "/usr/local/nginx/sbin/nginx"
#nginx modules path: "/usr/local/nginx/modules"
#nginx configuration prefix: "/usr/local/nginx/conf"
#nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
#nginx pid file: "/usr/local/nginx/logs/nginx.pid"
#nginx error log file: "/usr/local/nginx/logs/error.log"
#nginx http access log file: "/usr/local/nginx/logs/access.log"
#nginx http client request body temporary files: "/var/lib/nginx/body"
#nginx http proxy temporary files: "/var/lib/nginx/proxy"
#nginx http fastcgi temporary files: "/var/lib/nginx/fastcgi"
#nginx http uwsgi temporary files: "/var/lib/nginx/uwsgi"
#nginx http scgi temporary files: "/var/lib/nginx/scgi"
echo ">>>>>>>>>>build nginx<<<<<<<<<"
make && make install
cd /etc/init.d
wget -O nginx https://gitee.com/thx/shell/raw/master/nginx/nginx
#dos2unix nginx
chmod a+x /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
